package com.example.tianyidemo.service.impl;

import com.example.tianyidemo.Mapper.SectionAndCircleMapper;
import com.example.tianyidemo.pojo.Circle;
import com.example.tianyidemo.pojo.Section;
import com.example.tianyidemo.service.SectionAndCircleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class SectionAndCircleimpl implements SectionAndCircleService {
    private static final Logger logger = LoggerFactory.getLogger(SectionAndCircleimpl.class);
    //  service不能操作数据库，调用mapper接口
    @Autowired
    private SectionAndCircleMapper sectionAndCircleMapper;

    @Override
    public List<Section> getSAC() {
        List<Section> sectionAndCircleList = sectionAndCircleMapper.getSectionAndCircle();

        // 填充每个Section的circles属性
        for (Section section : sectionAndCircleList) {
            List<Circle> circles = sectionAndCircleMapper.getCirclesBySectionId(section.getSectionID());
            section.setCircles(circles);  // 修改方法名以匹配属性名
        }

        return sectionAndCircleList;
    }
}



